@prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh:   <http://www.w3.org/ns/shacl#> .
@prefix xsd:  <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix ex:  <http://example.org/> .

ex:Shape
	a sh:NodeShape ;         
    sh:and ( ex:PersonShape  ).               # AND the Person shape needs to be taken into account as well

ex:KnowsPieterShape 
	a sh:NodeShape ;
	sh:property [
		sh:node ex:PieterShape ;
		sh:path ex:knows
	] .

ex:PieterShape sh:property [
	sh:minCount 1 ;
	sh:path ex:name 
].
	
ex:PersonShape
	a sh:NodeShape ;
	sh:property [
		sh:node ex:PersonShape ;
		sh:path ex:knows
	];
	## If knows is provided, it should refer to a person, which needs to have a name
	sh:xone ( 
		# Or it has a property firstname and lastname, or it has a property name. If it has a property firstname, it must also have a property lastname or sirname.
			[ 
				sh:path ex:name ;
				sh:minCount 1 ;
			]
			[ 
					sh:property [
						sh:path ex:firstName ;
						sh:minCount 1
					];
					sh:xone (
						[ 
							sh:path ex:lastName ;
							sh:minCount 1
						]
						[
							sh:path ex:sirname;
							sh:minCount 1 
						]
					)
			]
		  ) .


# It has either a foaf:name, or it has a ex:qualifiedName
ex:XoneWithNodeShape a sh:NodeShape ;
	sh:xone ( [
		sh:path foaf:name; 
		sh:minCount 1 
	] [
		sh:property [
			sh:path ex:qualifiedName ;
			sh:node ex:QualifiedNameShape;
			sh:minCount 1 
		] 
	]) .

ex:QualifiedNameShape a sh:NodeShape ;
	sh:property [
		sh:minCount 1 ;
		sh:path ex:name ;
	], [
		sh:path ex:validUntil ;
		# ...
	] .


# A conditional that is a circular reference

ex:CircularXoneShape a sh:NodeShape ;
	sh:property [
		sh:minCount 1 ;
		sh:path ex:name
	] ;
	sh:xone (
		[ 
			sh:path ex:knows ;
			sh:node ex:CircularXoneShape ;
			sh:minCount 1
		]
		[
			sh:path ex:knows ;
			sh:node [
				sh:property [
					sh:path ex:name ;
					sh:minCount 1 
				]
			]
		]
	) .

ex:CircularOrShape a sh:NodeShape ;
	sh:property [
		sh:minCount 1 ;
		sh:path ex:name
	] ;
	sh:or (
		[ 
			sh:path ex:knows ;
			sh:node ex:CircularOrShape ;
			sh:minCount 1
		]
		[
			sh:path ex:knows ;
			sh:node [
				sh:property [
					sh:path ex:name ;
					sh:minCount 1 
				]
			]
		]
	) .

## A conditional case that should trigger an HTTP request: a xone in a xone with an optional property containing a node link

ex:TriggersHTTPShape a sh:NodeShape ;
	sh:xone (
		[
			sh:xone (
				[
					sh:path ex:qualifiedName ;
					sh:node ex:QualifiedNameShape
					
				]
			)
		]
	) .

### Should give a tempalte like this:
### { xone : [{ xone : { requiredProperties: qualifiedName, nodeLinks Map {"ex:qualifiedName" → "QualifiedNameShape"} } } ]}



### TODO: also test conditionals where actually nothing should happen as not all options are required properties.
